package com.bw.goods.controller;

import com.bw.common.core.domain.R;
import com.bw.common.core.web.controller.BaseController;
import com.bw.goods.domain.PmsSkuInfo;
import com.bw.goods.domain.ShoppingCart;
import com.bw.goods.service.DetailsInformationService;
import com.bw.goods.vo.ItemInfoVo;
import com.bw.goods.vo.ShoppingCartListDisplayFunctionVo;
import com.bw.goods.vo.ShoppingCartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * @Author：尚志豪
 * @Package：com.bw.goods.controller
 * @Project：ruoyiszh
 * @name：DetailsInformationController
 * @Date：2024/12/23 20:33
 */
@RestController
@RequestMapping("/detailsInformation")
public class DetailsInformationController extends BaseController {

    @Autowired
    private DetailsInformationService detailsInformationService;

    /**
     * 1.查sku详情   0.5s
     * 2.查sku图片信息 1s
     * 3.查spu相关信息销售属性 1s
     * 4.查spu商品介绍 1s
     * 5.查规格和包装 05s
     */
    @PostMapping("/selectSkuItemInfoBySkuId")
    public ItemInfoVo selectSkuItemInfoBySkuId( Long skuId) throws ExecutionException, InterruptedException {
        ItemInfoVo itemInfoVo = detailsInformationService.selectSkuItemInfoBySkuId(skuId);
        return itemInfoVo;
    }

    /**
     * 添加购物车
     */
    @PostMapping("/addSkuItemInfoShoppingCart")
    public R addSkuItemInfoShoppingCart(@RequestBody PmsSkuInfo pmsSkuInfo){
        detailsInformationService.addSkuItemInfoShoppingCart(pmsSkuInfo);
        return R.ok("添加成功");
    }

    /**
     * 购物车列表展示功能
     */
    @GetMapping("/searchAllShoppingCarts")
    public ShoppingCartListDisplayFunctionVo searchAllShoppingCarts()
    {
        ShoppingCartListDisplayFunctionVo list = detailsInformationService.searchAllShoppingCarts();
        return list;
    }
    /**
     * 购物车列表展示功能2
     */
    @GetMapping("/searchAllShoppingCarts2")
    public List<ShoppingCartVo> searchAllShoppingCarts2()
    {
        List<ShoppingCartVo> list = detailsInformationService.searchAllShoppingCarts2();
        return list;
    }

    /**
     * 删除购物车
     */
    @PostMapping("/deleteShoppingCart")
    public R deleteShoppingCart(@RequestParam Long skuId)
    {
        detailsInformationService.deleteShoppingCart(skuId);
        return R.ok("删除购物车成功");
    }









}
